<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.ListUsinaSituacaoTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">

            <p:growl id="messages" life="3000" />

            <h:panelGroup id="messagePanel" styleClass="ajustaListaMensagemErro"  layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="list"/>
            </h:panelGroup>

            <p:dataTable id="tbl" value="#{usinaSituacaoController.lista}" var="item"  paginator="true" rows="#{bundle.rows}" pageLinks="5" widgetVar="usinaSituacaoTable"
                         currentPageReportTemplate="#{bundle.currentPageReportTemplateUsinaSituacao}"  paginatorTemplate="#{bundle.paginatorTemplate}"
                         rowsPerPageTemplate="#{bundle.rowsPerPageTemplate}"  paginatorPosition="#{bundle.paginatorPosition}" emptyMessage="#{bundle.ListUsinaSituacaoEmpty}" 
                         rowKey="#{item.ussId}" selection="#{usinaSituacaoController.selectedUsinaSituacao}" selectionMode="single"
                         filteredValue="#{usinaSituacaoController.lista}" styleClass="mystyle">

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUsinaSituacaoTitle_ussId}"/>
                    </f:facet>
                    <h:outputText value="#{item.ussId}"/>
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUsinaSituacaoTitle_ussNm}"/>
                    </f:facet>
                    <h:outputText value="#{item.ussNm}"/>
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListUsinaSituacaoTitle_ussDs}"/>
                    </f:facet>
                    <h:outputText value="#{item.ussDs}"/>
                </p:column>
                
                <f:facet name="footer">                            
                    <p:commandButton id="createCommand" rendered="#{!autenticadorController.loginVisualizador}" ajax="false" icon="#{bundle.icone_documento}" action="#{usinaSituacaoController.prepareCreate}" value="#{bundle.ListUsinaSituacaoCreateLink}"/>
                    <p:commandButton id="viewCommand"  value="#{bundle.MsgVisualizar}" icon="#{bundle.icone_pesquisa}"  update=":formList:displayView" oncomplete="usinaSituacaoDialogView.show()" actionListener="#{usinaSituacaoController.prepareView}" />
                    <p:commandButton id="editCommand" ajax="false" action="#{usinaSituacaoController.prepareEdit}" value="#{bundle.ListUsinaSituacaoEditLink}" icon="#{bundle.icone_pencil}" rendered="#{autenticadorController.loginRestrito2}"/>
                    <p:commandButton id="deleteCommand" ajax="false" rendered="#{autenticadorController.loginRestrito2}" onclick="confirmationDestroy.show();" value="#{bundle.ListUsinaSituacaoDestroyLink}" type="button" icon="#{bundle.icone_lixeira}" />

                    <p:commandButton id="excelExportAll" ajax="false" value="#{bundle.excelExportAll}" icon="#{bundle.icone_script}">
                        <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportAllFileName_usinaSituacao}"  postProcessor="#{usinaSituacaoController.postProcessorXLS}"/>
                    </p:commandButton>
                    <p:commandButton id="excelExportPagAtual" ajax="false" value="#{bundle.excelExportPagAtual}" icon="#{bundle.icone_calculadora}">
                        <p:dataExporter type="xls" target="tbl" fileName="#{bundle.excelExportPagAtualFileName_usinaSituacao}" pageOnly="true"  postProcessor="#{usinaSituacaoController.postProcessorXLS}"/>
                    </p:commandButton>
                </f:facet>
            </p:dataTable>

            <p:confirmDialog id="confirmDestroy" message="#{bundle.MsgConfirmDestroy_message}" header="#{bundle.MsgConfirmDestroy_header}" severity="alert" widgetVar="confirmationDestroy">
                <p:commandButton id="confirm" ajax="false" value="#{bundle.MsgDialog_confirmar}"  oncomplete="confirmationDestroy.hide(); #{usinaSituacaoController.prepareList}" icon="#{bundle.icone_listar}" action="#{usinaSituacaoController.destroy}" update="tbl"/>
                <p:commandButton id="decline"  value="#{bundle.MsgDialog_cancelar}" update="messages" onclick="confirmationDestroy.hide();" type="button"/>

            </p:confirmDialog>

            <p:dialog id="dialogView" header="#{bundle.UsinaSituacaoDialogView_header}" widgetVar="usinaSituacaoDialogView" resizable="false" modal="true"
                      width="500" >

                <h:panelGrid id="displayView" columns="2" cellpadding="4">
                    <h:outputText value="#{bundle.ViewUsinaSituacaoLabel_ussId}"/>
                    <h:outputText value="#{usinaSituacaoController.selected.ussId}" title="#{bundle.ViewUsinaSituacaoTitle_ussId}"/>
                    <h:outputText value="#{bundle.ViewUsinaSituacaoLabel_ussNm}"/>
                    <h:outputText value="#{usinaSituacaoController.selected.ussNm}" title="#{bundle.ViewUsinaSituacaoTitle_ussNm}"/>
                    <h:outputText value="#{bundle.ViewUsinaSituacaoLabel_ussDs}"/>
                    <h:outputText value="#{usinaSituacaoController.selected.ussDs}" title="#{bundle.ViewUsinaSituacaoTitle_ussDs}"/>
                </h:panelGrid>
            </p:dialog>

        </ui:define>
    </ui:composition>

</html>
